package sc.love.boot.aop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import sc.love.boot.pojo.User;
import sc.love.boot.service.UserService;


/**
 * @ClassName StaticPorxy
 * @Description 静态代理
 * @Author 15393
 * @Date 2020/5/29 10:29
 * @Version V1.0
 */
@Service("StaticPorxy")
//@Primary
public class StaticPorxy implements UserService {

 //   private UserService userService;
    @Autowired
    ApplicationContext applicationContext;

//    public StaticPorxy() {
//        UserService bean = (UserService)applicationContext.getBean("UserService");
//        userService = bean;
//    }

    @Override
    public User checkUser(String userNumber, String password) {
        UserService bean = (UserService)applicationContext.getBean("UserServiceImpl");
        return bean.checkUser(userNumber, password);
    }
}